<?php

namespace IDock\Insurance\TAIC\Response;

use IDock\Http\Response;
use IDock\IDock\IDockEnums;
use IDock\Printer\ProposalStatusPrinter;
use IDock\Visitor\ProposalStatusVisitor;

class ProposalStatusResponse extends AllTAICResponse
{
    /**
     * @var ProposalStatusPrinter $printer
     */
    public $printer = ProposalStatusPrinter::class;

    /**
     * visitor
     * @var ProposalStatusVisitor $visitor
     */
    public $visitor;

    public function setVisitor($visitor)
    {
        $this->visitor = $visitor;
    }

    public function printerInit(): Response
    {
        $list = $this->get('proposalDataDtoList', [])[0] ?? [];

        $this->setBody($list);

        return $this;
    }

    public function init()
    {
        $this->printer->ciInquiryNo = $this->visitor->ciInquiryNo;
        $this->printer->biInquiryNo = $this->visitor->biInquiryNo;

        $this->printer->underDate = $this->get('undwrtTime');

        $status = $this->get('status');

        if ($status == '3' or $status == '1' or $status == 'c' or $status == 'C') {
            $this->printer->statusCode = 'U1';
        }

        if ($status == '2') {
            $this->printer->statusCode = 'U2';
        }

        if($status == '4'){
            $this->printer->statusCode = 'U6';//拒保
        }

        if ($status == '9') {
            $this->printer->statusCode = 'U3';
        }
        $this->printer->messageTip = $this->get('handleText');
        $this->printer->status = IDockEnums::$underStats[$this->printer->statusCode] ?? '';
    }
}
